package com.md.youyouhui.utils;

import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import com.md.youyouhui.net.Constants;
import com.md.youyouhui.ui.login.LoginActivity;


/**
 * Created by AdministratorZJ
 * on 2018/7/13.
 */

public class ToastUtils {
    private static final String TAG = "ToastUtils";

    public static void makeText(Activity context, String content) {
        Toast.makeText(context, content, Toast.LENGTH_SHORT).show();
    }

    public static void errMake(Activity context, int code) {
        if (code == 3000) {
            Toast.makeText(context, "参数为空", Toast.LENGTH_SHORT).show();
        } else if (code == 3001) {
            Toast.makeText(context, "Token无效，请重新登录", Toast.LENGTH_SHORT).show();
            SharedPreferencesUtils.saveString(context, Constants.USER_TOKEN, "");
            /*SharedPreferencesUtils.saveString(context, Constants.NICK_NAME, "");
            SharedPreferencesUtils.saveInt(context, Constants.USER_SEX, 1);
            SharedPreferencesUtils.saveString(context, Constants.USER_PHONE, "");
            SharedPreferencesUtils.saveString(context, Constants.USER_HEAD, "");
            SharedPreferencesUtils.saveString(context, Constants.CHILD_ID, "");
            SharedPreferencesUtils.saveString(context, Constants.CHILD_NAME, "");*/
            Log.e(TAG, "errMake: 3000000000000000000000001");
            AppManager.getAppManager().finishAllActivity();
            context.startActivity(new Intent(context, LoginActivity.class));
            context.finish();
        } else if (code == 3002) {
            Toast.makeText(context, "短信验证码无效", Toast.LENGTH_SHORT).show();
        } else if (code == 3003) {
            Toast.makeText(context, "帐户不存在", Toast.LENGTH_SHORT).show();
        } else if (code == 3004) {
            Toast.makeText(context, "用户名或密码不正确,登录授权失败", Toast.LENGTH_SHORT).show();
        } else if (code == 3005) {
            Toast.makeText(context, "未找到账号信息", Toast.LENGTH_SHORT).show();
        } else if (code == 3006) {
            Toast.makeText(context, "旧密码错误", Toast.LENGTH_SHORT).show();
        } else if (code == 3007) {
            Toast.makeText(context, "账户已被停用", Toast.LENGTH_SHORT).show();
        } else if (code == 3008) {
            Toast.makeText(context, "已绑油卡", Toast.LENGTH_SHORT).show();
        } else if (code == 3009) {
            Toast.makeText(context, "帐户已存在", Toast.LENGTH_SHORT).show();
        } else if (code == 3010) {
            Toast.makeText(context, "优惠券不可以使用", Toast.LENGTH_SHORT).show();
        } else if (code == 3011) {
            Toast.makeText(context, "文件不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 3012) {
            Toast.makeText(context, "今日无法领取", Toast.LENGTH_SHORT).show();
        } else if (code == 3013) {
            Toast.makeText(context, "调起支付宝失败", Toast.LENGTH_SHORT).show();
        } else if (code == 3014) {
            Toast.makeText(context, "邀请人不存在", Toast.LENGTH_SHORT).show();
        } else if (code == 3015) {
            Toast.makeText(context, "已领取新人奖励", Toast.LENGTH_SHORT).show();
        } else if (code == 3016) {
            Toast.makeText(context, "账单不匹配", Toast.LENGTH_SHORT).show();
        } else if (code == 3017) {
            Toast.makeText(context, "该时间段暂停充值", Toast.LENGTH_SHORT).show();
        }  else if (code == 3018) {
            Toast.makeText(context, "默认地址无法删除", Toast.LENGTH_SHORT).show();
        } else if (code == 3019) {
            Toast.makeText(context, "调起微信支付失败", Toast.LENGTH_SHORT).show();
        } /*else if (code == 4017) {
            Toast.makeText(context, "未佩戴手表", Toast.LENGTH_SHORT).show();
        } else if (code == 4018) {
            Toast.makeText(context, "未获取数据(心率)", Toast.LENGTH_SHORT).show();
        } else if (code == 4019) {
            Toast.makeText(context, "没有访问权限", Toast.LENGTH_SHORT).show();
        } else if (code == 4020) {
            Toast.makeText(context, "手表不在线", Toast.LENGTH_SHORT).show();
        } else if (code == 4021) {
            Toast.makeText(context, "兑换数量不足", Toast.LENGTH_SHORT).show();
        } else if (code == 4022) {
            Toast.makeText(context, "未找到文件", Toast.LENGTH_SHORT).show();
        } else if (code == 4023) {
            Toast.makeText(context, "未找到巡检项目", Toast.LENGTH_SHORT).show();
        } else if (code == 4024) {
            Toast.makeText(context, "时间选择错误", Toast.LENGTH_SHORT).show();
        } else if (code == 4025) {
            Toast.makeText(context, "请假中", Toast.LENGTH_LONG).show();
        } else if (code == 4026) {
            Toast.makeText(context, "重复添加好友号码", Toast.LENGTH_SHORT).show();
        } else if (code == 4027) {
            Toast.makeText(context, "假条代课未处理完成", Toast.LENGTH_SHORT).show();
        } else if (code == 4028) {
            Toast.makeText(context, "操作失败（需刷新处理）", Toast.LENGTH_SHORT).show();
        } else if (code == 4029) {
            Toast.makeText(context, "Uface注册失败", Toast.LENGTH_SHORT).show();
        } else if (code == 4030) {
            Toast.makeText(context, "Uface图片上传失败", Toast.LENGTH_SHORT).show();
        } else if (code == 4031) {
            Toast.makeText(context, "Uface用户未注册", Toast.LENGTH_SHORT).show();
        } else if (code == 4032) {
            Toast.makeText(context, "Uface用户已注册", Toast.LENGTH_SHORT).show();
        } else if (code == 4033) {
            Toast.makeText(context, "没有权限", Toast.LENGTH_SHORT).show();
        } else if (code == 4034) {
            Toast.makeText(context, "不需要签到", Toast.LENGTH_SHORT).show();
        } else if (code == 4035) {
            Toast.makeText(context, "不能找人代课(不是公假不让代课)", Toast.LENGTH_SHORT).show();
        } else if (code == 4036) {
            Toast.makeText(context, "类型名称不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4037) {
            Toast.makeText(context, "领用数量不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4038) {
            Toast.makeText(context, "未找到用户", Toast.LENGTH_SHORT).show();
        } else if (code == 4039) {
            Toast.makeText(context, "未找到物资", Toast.LENGTH_SHORT).show();
        } else if (code == 4040) {
            Toast.makeText(context, "剩余数量不足", Toast.LENGTH_SHORT).show();
        } else if (code == 4041) {
            Toast.makeText(context, "类型id不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4042) {
            Toast.makeText(context, "未找到类型", Toast.LENGTH_SHORT).show();
        } else if (code == 4043) {
            Toast.makeText(context, "物品名称不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4044) {
            Toast.makeText(context, "生产日期不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4045) {
            Toast.makeText(context, "保质期不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4046) {
            Toast.makeText(context, "入库时间不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4047) {
            Toast.makeText(context, "基本单位不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4048) {
            Toast.makeText(context, "单位层数不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4049) {
            Toast.makeText(context, "打印数量不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4050) {
            Toast.makeText(context, "提交人员不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4051) {
            Toast.makeText(context, "入库人员不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4052) {
            Toast.makeText(context, "单位层数有误", Toast.LENGTH_SHORT).show();
        } else if (code == 4053) {
            Toast.makeText(context, "物资id不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4054) {
            Toast.makeText(context, "删除类型不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4055) {
            Toast.makeText(context, "物资已删除", Toast.LENGTH_SHORT).show();
        } else if (code == 4056) {
            Toast.makeText(context, "商品条形码不能为空", Toast.LENGTH_SHORT).show();
        } else if (code == 4057) {
            Toast.makeText(context, "巡检次数已达上限", Toast.LENGTH_SHORT).show();
        } else if (code == 4058) {
            Toast.makeText(context, "与上次巡检时间间隔过短", Toast.LENGTH_SHORT).show();
        } else if (code == 4059) {
            Toast.makeText(context, "假条已经提交，不可操作", Toast.LENGTH_SHORT).show();
        } else if (code == 4060) {
            Toast.makeText(context, "未找到作业", Toast.LENGTH_SHORT).show();
        } else if (code == 4061) {
            Toast.makeText(context, "未找到学生", Toast.LENGTH_SHORT).show();
        } else if (code == 4062) {
            Toast.makeText(context, "回复已存在", Toast.LENGTH_SHORT).show();
        }
        if (code == 5000) {
            Toast.makeText(context, "不支持POST请求", Toast.LENGTH_SHORT).show();
        }*/ else if (code == 5001) {
            Toast.makeText(context, "服务器发生错误", Toast.LENGTH_SHORT).show();
        } else if (code == 5002) {
            Toast.makeText(context, "数据保存失败", Toast.LENGTH_SHORT).show();
        } else if (code == 5003) {
            Toast.makeText(context, "数据删除失败", Toast.LENGTH_SHORT).show();
        } /*else if (code == 5004) {
            Toast.makeText(context, "操作频繁", Toast.LENGTH_SHORT).show();
        }*/ else if (code == 6000) {
            Toast.makeText(context, "数据不存在", Toast.LENGTH_SHORT).show();
        } /*else if (code == 6002) {
            Toast.makeText(context, "融云平台更新用户失败", Toast.LENGTH_SHORT).show();
        } else if (code == 6003) {
            Toast.makeText(context, "监护人校验失败", Toast.LENGTH_SHORT).show();
        } else if (code == 6004) {
            Toast.makeText(context, "激活失败,手机号码已被选", Toast.LENGTH_SHORT).show();
        } else if (code == 6005) {
            Toast.makeText(context, "激活失败,手表已被激活", Toast.LENGTH_SHORT).show();
        }*/ else if (code == 999) {
            Toast.makeText(context, "连接服务器失败", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(context, "未知错误" + code, Toast.LENGTH_SHORT).show();
        }

    }
}
